<!DOCTYPE html>
<html>

<head lang="en">
  <meta charset="UTF-8">
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  <meta http-equiv="Cache-Control" content="no-cache">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui"
  />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <title>Test</title>
</head>

<body>
  <div id="log">111111111111</div>
  <input type="button" value="ChooseImage" onclick="chooseImage()" />
  <input type="button" value="PreviewImage" onclick="previewImage()" />
  <input type="button" value="PhoneCall" onclick="phoneCall()" />
  <input type="button" value="Market" onclick="market()" />
  <script language="javascript" type="text/javascript" src="./bridge.js"></script>
  <script language="javascript" type="text/javascript" src="//page.iju.cn/js/app/app.js"></script>
  <script>
    var log = document.getElementById('log');
    log.innerText = typeof WebViewJavascriptBridge;

    var chooseResult;
    function chooseImage() {
      WebViewJavascriptBridge.callHandler("chooseImage", { count: 2 }, function (res) {
        chooseResult = res;
        log.innerHTML = "";
        add("size: " + res.images.length);
      });
    };

    function previewImage() {
      if (chooseResult) {
        var array = [];
        for (var i = 0; i < chooseResult.images.length; i++) {
          array.push(chooseResult.images[i]);
        }
        chooseResult = null;
        WebViewJavascriptBridge.callHandler("previewImage", { urls: array }, null);
      }
    };

    function phoneCall() {
      WebViewJavascriptBridge.callHandler("makePhoneCall", { phoneNumber: "13877160317" }, null);
    }

    function add(msg) {
      var line = document.createElement("p");
      line.innerText = msg;
      log.appendChild(line);
    }

    function market() {
      window.location.href = "market://details?id=com.yooee.headline"
    }
  </script>
</body>

</html>